#!/usr/bin/perl -w

print("function FindProxyForURL(url,host){
      if(isPlainHostName(host)||
         dnsDomainIs(host,\".ieee.org\")||
	 isInNet(host,\"127.0.0.1\",\"255.255.255.255\")||
	 isInNet(host,\"192.168.10.0\",\"255.255.255.0\"))
	return \"DIRECT\"\;\n");

my $freelist=shift;
my $proxylist=shift;

open(FREEIP,"<$freelist");
while(<FREEIP>){
    chomp;
    my $f_addr;
    my $f_set;  #trivial
    my $f_mask;
    ($f_addr,$f_set,$f_mask)=split;
    print("else if(isInNet(host,\"$f_addr\",\"$f_mask\"))
        return \"DIRECT\"\;\n");
}
close(FREEIP);

open(PROXY,"<$proxylist");
print(
"else
    return \"");
while(<PROXY>){
    chomp;
    if($_){
    	print("PROXY $_\; ");
    }
}

print("DIRECT \"\;
}\n");

